//*****************************************************************************
// FILE:            WinMTRLicense.cpp
//
//    Copyleft (C) 2000-2002, Vasile Laurentiu Stanimir ( stanimir@cr.nivis.com )    
//
//*****************************************************************************

#include "WinMTRGlobal.h"
#include "WinMTRLicense.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//*****************************************************************************
// BEGIN_MESSAGE_MAP
//
// 
//*****************************************************************************
BEGIN_MESSAGE_MAP(WinMTRLicense, CDialog)
END_MESSAGE_MAP()


//*****************************************************************************
// WinMTRLicense::WinMTRLicense
//
// 
//*****************************************************************************
WinMTRLicense::WinMTRLicense(CWnd* pParent) : CDialog(WinMTRLicense::IDD, pParent)
{
}


//*****************************************************************************
// WinMTRLicense::DoDataExchange
//
// 
//*****************************************************************************
void WinMTRLicense::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT_LICENSE, m_editLicense);
}


//*****************************************************************************
// WinMTRLicense::OnInitDialog
//
// 
//*****************************************************************************
BOOL WinMTRLicense::OnInitDialog() 
{
	char buf[1024];
	CDialog::OnInitDialog();
	
	FILE *fp;

	fp = fopen("LICENSE.TXT", "rt");
	if(fp==NULL) {
		m_editLicense.SetWindowText("File LICENSE.TXT not found"); 
		return FALSE;
	}

	while(!feof(fp)) {
		if(fgets(buf, 1024, fp)==NULL)
			continue;

		if(strlen(buf)>0)
			buf[strlen(buf)-1] = '\0';
		strcat(buf,"\r\n");
		
		m_editLicense.SetSel(-1, -1);
		m_editLicense.ReplaceSel(buf);
	}

	return FALSE;
}

